import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { TypeOrmModule } from '@nestjs/typeorm';
import { UserModule } from './api/user/user.module';
import { MenuModule } from './api/menu/menu.module';
import appConfig from './config/index'
import { ConfigModule, ConfigService } from '@nestjs/config'
@Module({
  imports: [
    ConfigModule.forRoot({
      load: appConfig,
      isGlobal: true
    }),

    TypeOrmModule.forRootAsync({
      imports: [ConfigModule],
      inject: [ConfigService],
      useFactory: (configService: ConfigService) => ({
        type: 'mysql',
        host: 'localhost',
        port: 3306,
        username: 'root',
        password: '',
        database: 'role_auth',
        entities: [__dirname + '/**/*.entity{.ts,.js}'],
      }),
    }),
    UserModule,MenuModule,
  //     UserModule,MenuModule,TypeOrmModule.forRoot({
  //
  //   type: 'mysql',
  //   host: 'localhost',
  //   port: 3306,
  //   username: 'root',
  //   password: '',
  //   database: 'role_auth',
  //   entities: [__dirname + '/**/*.entity{.ts,.js}'],
  //   // synchronize: true
  // })
  ],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule {}
